package cn.dw.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import cn.dw.dao.UserDao;
import cn.dw.domain.User;

public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {
	@SuppressWarnings("unchecked")
	public User getByUserName(String username) {
		DetachedCriteria dc = DetachedCriteria.forClass(User.class);
		dc.add(Restrictions.eq("username", username));
		List<User> list = getHt().findByCriteria(dc);
		return (list != null) && (list.size() > 0) ? (User) list.get(0) : null;
	}
}
